package com.tuling.test.autowire;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {

	//这种方式可以拿到orderService值,但是已经废弃了,不建议再使用
	/*
		@Bean(autowire = Autowire.BY_TYPE)
		public UserService userService(){
			UserService userService = new UserService();
			return userService;
		}
	*/

	@Bean({"userService","userService1","userService2"})
	public UserService userService(OrderService orderService){
		UserService userService = new UserService();
		userService.setOrderService(orderService);
		return userService;
	}

	@Bean
	public OrderService orderService(){
		return new OrderService();
	}
}
